package edu.hawaii.senin.iclouds.basics;

import static org.junit.Assert.assertEquals;

import org.junit.Before;
import org.junit.Test;


/**
 * Tests normal Atom operations.
 * 
 * @author Administrator.
 * 
 */
public class TestMolecule {
  /**
   * test Molecule1.
   */
  private Molecule Molecule1;
  /**
   * test Molecule2.
   */
  private Molecule Molecule2;
  /**
   * test Abundance1.
   */
  private final Double Abundance1 = Double.valueOf(0.33);
  /**
   * test Abundance2.
   */
  private final Double Velocity1 = Double.valueOf(5.33);

  /**
   * Little test fixture.
   */
  @Before
  public void runBeforeEachTest() {
    Molecule1 = new Molecule();
    Molecule2 = new Molecule();
  }

  /**
   * Tests abundance setter and getter.
   * 
   */
  @Test
  public void testSetAndGetAbundance() {
    Molecule1.setAbundance(Abundance1);
    assertEquals("Testing value operations.", Molecule1.getAbundance().doubleValue(), Abundance1
        .doubleValue());
  }

  /**
   * Tests velocity setter and getter.
   * 
   */
  @Test
  public void testSetAndGetVelocity() {
    Molecule1.setVelocity(Velocity1);
    assertEquals("Testing velocity operations.", Molecule1.getVelocity().doubleValue(), Velocity1
        .doubleValue());
  }

  /**
   * Tests name setter and getter.
   * 
   */
  @Test
  public void testSetAndGetName() {
    Molecule1.setName("H");
    assertEquals("Testing equals method.", Molecule1.getName(), "H");
  }

  /**
   * Tests Molecule comparison.
   * 
   */
  @Test
  public void testComparisons() {
    Molecule1.setName("H");
    Molecule2.setName("H");
    assertEquals("Testing equal operations", true, Molecule1.equals(Molecule2));

    Molecule2.setName("C");
    assertEquals("Testing comparison operations", false, Molecule1.equals(Molecule2));

    assertEquals("Testing comparison operations", true, Molecule2.compareTo(Molecule1) < 0);
    assertEquals("Testing comparison operations", true, Molecule1.compareTo(Molecule2) > 0);
    assertEquals("Testing hash code operations", 
        true, Molecule1.hashCode() == Molecule1.hashCode());
    assertEquals("Testing hash code operations", false, Molecule1.hashCode() == Molecule2
        .hashCode());

  }

}
